import grails.test.GrailsUnitTestCase
import grails.test.MockUtils

class TradeTests extends GrailsUnitTestCase {
    public void testNullableConstraints() {
        // Mock the validate() method.
        registerMetaClass(Trade)
        MockUtils.prepareForConstraintsTests(Trade)

        def testInstance = new Trade()
        def errors = testInstance.validate()
        assertEquals 1, errors.size()
        assertEquals "nullable", errors["tradeName"]
    }

    public void testBlankConstraints() {
        // Mock the validate() method.
        registerMetaClass(Trade)
        MockUtils.prepareForConstraintsTests(Trade)

        def testInstance = new Trade(tradeName:'  ')
        def errors = testInstance.validate()
        assertEquals 1, errors.size()
        assertEquals "blank", errors["tradeName"]
    }
}